{% extends "StartGroup/groupHome.html" %}

{% block view_poll %}
<h3>Polls</h3>
<a href="{% url polls.views.add_poll %}">Create New Poll</a>
<div class='PollIndex'>
    {% if poll_pages.object_list %}
        <table class='PollDetail' width="65%">
            <div class='PollHeader'>
                <tr>
                        <th align='char'>Poll</th>
                        <th align='char'>Started</th>
                        <th align='char'>Response</th>
                </tr>
            </div>
            {% for each in poll_pages.object_list %}
            <tr>
                    <td>{{ each.0.poll_topic }}
                        <a href="{{ each.0.id }}/vote">Vote!</a>
                    </td>
                    <td>{{ each.0.pub_date }}</td>
                    <td>{{ each.1 }} so far</td>
            </tr>
            {% endfor %}
        </table>
</div>
    {% else %}
    <div class="PollPages">
        {% if poll_pages.has_previous %}
            <a href="?page={{ pages.previous_page_number }}">previous</a>
        {% endif %}
    
        <span>
            Page {{ poll_pages.number }} of {{ poll_pages.paginator.num_pages }}
        </span>
    
        {% if poll_pages.has_next %}
            <a href="?page={{ pages.next_page_number }}">next</a>
        {% endif %}
    </div>
        <p>No polls are available.</p>
    {% endif %}
{% endblock %}
